package com.htc.android.footprints.utils;

import android.util.Log;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

public class ExifInterface
{
  static final int ORIENTATION_FLIP_HORIZONTAL = 2;
  static final int ORIENTATION_FLIP_VERTICAL = 4;
  static final int ORIENTATION_NORMAL = 1;
  static final int ORIENTATION_ROTATE_180 = 3;
  static final int ORIENTATION_ROTATE_270 = 8;
  static final int ORIENTATION_ROTATE_90 = 6;
  static final int ORIENTATION_TRANSPOSE = 5;
  static final int ORIENTATION_TRANSVERSE = 7;
  static final int ORIENTATION_UNDEFINED = 0;
  static final String TAG_DATE_TIME_ORIGINAL = "DateTimeOriginal";
  static final String TAG_FLASH = "Flash";
  static final String TAG_GPS_LATITUDE = "GPSLatitude";
  static final String TAG_GPS_LATITUDE_REF = "GPSLatitudeRef";
  static final String TAG_GPS_LONGITUDE = "GPSLongitude";
  static final String TAG_GPS_LONGITUDE_REF = "GPSLongitudeRef";
  static final String TAG_IMAGE_LENGTH = "ImageLength";
  static final String TAG_IMAGE_WIDTH = "ImageWidth";
  static final String TAG_MAKE = "Make";
  static final String TAG_MODEL = "Model";
  static final String TAG_ORIENTATION = "Orientation";
  private HashMap<String, String> mCachedAttributes = null;
  private String mFilename;
  private boolean mHasThumbnail = false;
  private boolean mSavedAttributes = false;

  static
  {
    System.loadLibrary("exif_footprint");
  }

  public ExifInterface(String paramString)
  {
    this.mFilename = paramString;
  }

  private native boolean appendThumbnailNative(String paramString1, String paramString2);

  private native void commitChangesNative(String paramString);

  public static String convertRationalLatLonToDecimalString(String paramString1, String paramString2, boolean paramBoolean)
  {
    while (true)
    {
      Object localObject;
      try
      {
        String[] arrayOfString1 = paramString1.split(",");
        String[] arrayOfString2 = arrayOfString1[0].split("/");
        int i = (int)(Float.parseFloat(arrayOfString2[0].trim()) / Float.parseFloat(arrayOfString2[1].trim()));
        String[] arrayOfString3 = arrayOfString1[1].split("/");
        int j = (int)(Float.parseFloat(arrayOfString3[0].trim()) / Float.parseFloat(arrayOfString3[1].trim()));
        String[] arrayOfString4 = arrayOfString1[2].split("/");
        float f = Float.parseFloat(arrayOfString4[0].trim()) / Float.parseFloat(arrayOfString4[1].trim());
        String str1 = String.valueOf(i + j / 60.0F + f / 3600.0F);
        if (!paramBoolean)
          continue;
        if (!paramString2.equals("S"))
        {
          if (!paramString2.equals("E"))
            break label242;
          break label232;
          localObject = str3 + str1;
          break label239;
          String str2 = str1 + String.valueOf('º') + " " + paramString2;
          localObject = str2;
        }
      }
      catch (Exception localException)
      {
        localObject = null;
      }
      label232: String str3 = "-";
      continue;
      label239: return localObject;
      label242: str3 = "";
    }
  }

  private native String getAttributesNative(String paramString);

  private native byte[] getThumbnailNative(String paramString);

  public static String makeLatLongString(double paramDouble)
  {
    double d1 = Math.abs(paramDouble);
    int i = (int)d1;
    double d2 = d1 - i;
    int j = (int)(d2 * 60.0D);
    int k = (int)(1000.0D * (60.0D * (d2 * 60.0D - j)));
    return i + "/1," + j + "/1," + k + "/1000";
  }

  public static String makeLatStringRef(double paramDouble)
  {
    if (paramDouble >= 0.0D);
    for (String str = "N"; ; str = "S")
      return str;
  }

  public static String makeLonStringRef(double paramDouble)
  {
    if (paramDouble >= 0.0D);
    for (String str = "W"; ; str = "E")
      return str;
  }

  public static String orientationToString(int paramInt)
  {
    String str;
    switch (paramInt)
    {
    default:
      str = "Undefined";
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
    case 8:
    }
    while (true)
    {
      return str;
      str = "Normal";
      continue;
      str = "Flipped horizontal";
      continue;
      str = "Rotated 180 degrees";
      continue;
      str = "Upside down mirror";
      continue;
      str = "Transposed";
      continue;
      str = "Rotated 90 degrees";
      continue;
      str = "Transversed";
      continue;
      str = "Rotated 270 degrees";
    }
  }

  private native void saveAttributesNative(String paramString1, String paramString2);

  public boolean appendThumbnail(String paramString)
  {
    if (!this.mSavedAttributes)
      throw new RuntimeException("Must call saveAttributes before calling appendThumbnail");
    this.mHasThumbnail = appendThumbnailNative(this.mFilename, paramString);
    return this.mHasThumbnail;
  }

  public void commitChanges()
  {
    if (!this.mSavedAttributes)
      throw new RuntimeException("Must call saveAttributes before calling commitChanges");
    commitChangesNative(this.mFilename);
  }

  public HashMap<String, String> getAttributes()
  {
    if (this.mCachedAttributes != null);
    for (HashMap localHashMap = this.mCachedAttributes; ; localHashMap = this.mCachedAttributes)
    {
      return localHashMap;
      this.mCachedAttributes = new HashMap();
      String str1 = getAttributesNative(this.mFilename);
      int i = str1.indexOf(' ');
      int j = Integer.parseInt(str1.substring(0, i));
      int k = i + 1;
      int m = 0;
      if (m >= j)
        continue;
      int n = str1.indexOf('=', k);
      String str2 = str1.substring(k, n);
      int i1 = n + 1;
      int i2 = str1.indexOf(' ', i1);
      int i3 = Integer.parseInt(str1.substring(i1, i2));
      int i4 = i2 + 1;
      String str3 = str1.substring(i4, i4 + i3);
      k = i4 + i3;
      if (str2.equals("hasThumbnail"))
        this.mHasThumbnail = str3.equalsIgnoreCase("true");
      while (true)
      {
        m++;
        break;
        this.mCachedAttributes.put(str2, str3);
      }
    }
  }

  public byte[] getThumbnail()
  {
    return getThumbnailNative(this.mFilename);
  }

  public boolean hasThumbnail()
  {
    if (!this.mSavedAttributes)
      getAttributes();
    return this.mHasThumbnail;
  }

  public void saveAttributes(HashMap<String, String> paramHashMap)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    int i = paramHashMap.size();
    if (paramHashMap.containsKey("hasThumbnail"))
      i--;
    localStringBuilder.append(i + " ");
    Iterator localIterator = paramHashMap.keySet().iterator();
    while (localIterator.hasNext())
    {
      String str2 = (String)localIterator.next();
      if (str2.equals("hasThumbnail"))
        continue;
      String str3 = (String)paramHashMap.get(str2);
      localStringBuilder.append(str2 + "=");
      localStringBuilder.append(str3.length() + " ");
      localStringBuilder.append(str3);
    }
    String str1 = localStringBuilder.toString();
    Log.i("exif", "file name = " + this.mFilename);
    saveAttributesNative(this.mFilename, str1);
    this.mSavedAttributes = true;
  }
}

/* Location:           E:\workspace\dex2java\dex-translator-0.0.9.3\HtcFootprints_dex2jar.jar
 * Qualified Name:     com.htc.android.footprints.utils.ExifInterface
 * JD-Core Version:    0.6.0
 */